package cn.px.service.store.impl;

import com.github.pagehelper.PageHelper;
import cn.px.common.bean.AbstractPageResultBean;
import cn.px.dao.bean.MyPage;
import cn.px.dao.dto.store.SpareBackDetailDTO;
import cn.px.dao.entity.store.SpareBackDetail;
import cn.px.dao.mapper.store.SpareBackDetailMapper;
import cn.px.dao.vo.query.store.SpareBackDetailVO;
import cn.px.service.base.impl.BaseServiceImpl;
import cn.px.service.store.SpareBackDetailService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.weekend.Weekend;
import tk.mybatis.mapper.weekend.WeekendCriteria;

import java.util.List;

/**
 * @Description 备件领用详情 service 实现类
 * @author 品讯科技
 * @date 2024-08
 * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
 */
@AllArgsConstructor
@Service("spareBackDetailService")
public class SpareBackDetailServiceImpl extends BaseServiceImpl<SpareBackDetailMapper, SpareBackDetail, SpareBackDetailDTO> implements SpareBackDetailService {

    @Override
    public int batchDelete(List<String> ids) {
        Weekend<SpareBackDetail> weekend = new Weekend<>(SpareBackDetail.class);
        WeekendCriteria<SpareBackDetail, Object> weekendCriteria = weekend.weekendCriteria();
        weekendCriteria.andIn(SpareBackDetail::getId, ids);
        mapper.deleteByExample(weekend);
        return 1;
    }

    @Override
    public AbstractPageResultBean<SpareBackDetailVO> selectPageList(SpareBackDetailDTO record, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new MyPage(mapper.selectList(record));
    }

    @Override
    public AbstractPageResultBean<SpareBackDetail> selectPageInfo(SpareBackDetailDTO record, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new MyPage(mapper.selectList(record));
    }
}
